package com.oilsoft.shared.manager
{
	import com.oilsoft.shared.vos.User;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	public class SessionManager extends EventDispatcher
	{
		private var dispatcher:IEventDispatcher;
        private static var session:SessionManager=null;
		
		public static function getInstance():SessionManager{
			if(session==null){
				return null;
			}
			return session;
		}
		
		public function SessionManager(dispatcher:IEventDispatcher)
		{
			this.dispatcher = dispatcher;
			session=this;
		}
		
		
		private var _currentUser:User = new User();
		
		[Bindable( "currentUserChange" )]
		
		/**
		 * Current User
		 */
		public function getCurrentUser():User
		{
			return _currentUser;
		}
		
		public function setCurrentUser( value:User ):void
		{
			if ( _currentUser != value )
			{
				_currentUser = value;
				dispatchEvent( new Event( "currentUserChange" ) );
			}
		}
	}
}